package heven.holt.eyepetizer.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.hilt.android.AndroidEntryPoint
import heven.holt.eyepetizer.adapter.EyeHomeViewPagerAdapter
import heven.holt.eyepetizer.databinding.EyeFragmentMainBinding
import heven.holt.eyepetizer.utils.EyeMainNavigation
import heven.holt.library.base.BaseFragment
import timber.log.Timber

@AndroidEntryPoint
class EyeMainFragment : BaseFragment<EyeFragmentMainBinding>() {
    override fun bindViewBinding(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): EyeFragmentMainBinding = EyeFragmentMainBinding.inflate(inflater, container, false)

    private val eyeMainNavigation: EyeMainNavigation by lazy {
        EyeMainNavigation(binding, { index ->
            binding.viewPager.setCurrentItem(index, false)
        }, { index ->
            Timber.e("clickDouble=$index")
        })
    }

    override fun initView() {
        val commonViewPagerAdapter = EyeHomeViewPagerAdapter(this)
        binding.viewPager.adapter = commonViewPagerAdapter
        binding.viewPager.offscreenPageLimit = 4
    }

    override fun initData() {
        binding.handlers = MyHandlers()
    }

    inner class MyHandlers {
        fun navigation(view: View) {
            eyeMainNavigation.navigation(view)
        }
    }
}